#__*__coeding:utf-8__*__
#!/usr/share/python
'''
---------------------------------------------------------------- 
 版权所有。  
 
 文件名：
 文件功能描述： 
 author：
 时间：
--------------------------------------------------------------- 
'''



# from Base.Base import Base
# from Text.TextDispose import TxetDispose
# import os
# from collections import Counter
# import urllib.request,urllib.parse,json
# from UserAnalysis.UserAnalysis import UserAnalysis
# from DB.dbbase import dbbase

# conf_name=Base.conf()
# print(conf_name,'\n')
#

# UserAn=UserAnalysis.referer_addr_repeat(UserAnalysis)
# print(UserAn)

# Useran=UserAnalysis.list_repeat(UserAnalysis)
# print(Useran)

#Useran=UserAnalysis.forwarded_for_repeat(UserAnalysis)

# time_local = us[0]
# access_agen = us[1]
# access_forwarded_for = us[2]
# access_ip = us[3]
# accsess_referer = us[5]
# access_request = us[4]


# sql="SELECT * FROM t_order LEFT JOIN customer on customer_id=user_id WHERE `status`=2 OR `status`=9 OR `status`=5"
# #
# db_str=dbbase()
# data=db_str.getAll(sql)
# print(data)

# s=UserAnalysis.accsee_ip(UserAnalysis)
# print(s)


# from Model.Data_Model import IP_Model
# from Model.Data_Model import Access_time_Model
# #
# s=IP_Model.insert_ipdata(IP_Model)
# print(s)

# from Base.config import conf
#
# con=conf.get_conf(conf,flag='DB_config')
# print(con)




# from Text.TextDispose import log_dispose
#
# ll=log_dispose.baselogdispose(log_dispose,)
# print(ll)

# import re
# ll='access.log-20170505.gz'
# # if re.match(r'^access.log-\d{8}.gz$',ll):
# #     print(True)
# # elif re.match(r'^access.log-\d{8}|[0-9]$',ll):
# #     print(True)
# # else:
# #     print(False)
# # ls=ll.split('-')
# ls=re.sub(r'\D','',ll)
# print(ls)

# from Model.Data_Model import cont_or_logdate
#
# con=cont_or_logdate
# res=con.get_logdate_all(con)
# print(res)

# from Text.TextDispose import log_dispose
#
# print(log_dispose.unzip(log_dispose,file_name='E:\\nginx\\nginx\\access.log-20170627.gz'))

# from Text.TextDispose import log_dispose
#
#
# print(log_dispose.move_old_file(log_dispose,file_name='access.log-20170627.gz'))

# from Model.Data_Model import cont_or_logdate
#
# res=cont_or_logdate.get_logdate_all(cont_or_logdate)
# print(res)

# import time
# import os
# import sched
#
# # 初始化sched模块的scheduler类
# # 第一个参数是一个可以返回时间戳的函数，第二个参数可以在定时未到达之前阻塞。
# schedule = sched.scheduler(time.time, time.sleep)
#
#
# # 被周期性调度触发的函数
# def execute_command(cmd, inc):
#     '''''
#     终端上显示当前计算机的连接情况
#     '''
#     os.system(cmd)
#     schedule.enter(inc, 0, execute_command, (cmd, inc))
#
#
# def main(cmd, inc=None):
#     # enter四个参数分别为：间隔事件、优先级（用于同时间到达的两个事件同时执行时定序）、被调用触发的函数，
#     # 给该触发函数的参数（tuple形式）
#     schedule.enter(0, 0, execute_command, (cmd, inc))
#     schedule.run()
#
#
# # 每60秒查看下网络连接情况
# if __name__ == '__main__':
#     u_period=7
#     b_period=86400
#     res_period=u_period*b_period
#     while True:
#         main("netstat -an", res_period)

# ll={"period":'123','execution_time':'20：15：00','perform_number':'12'}
# print(ll['period'],ll['execution_time'],ll['perform_number'])
# import time
# print(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))
#from Model.DBL import seting
#
# getsettingcalss=seting
# result=getsettingcalss.get_last(getsettingcalss)
# print(result)

# from Base.tools import tools
# from Model.DBL import seting
# from contrl.setting_contrl import setting_constr
#
# # data = seting.get_last(seting)[1]
# # PRIMERS_DAY = 86400
# # now_date_day = tools.str_to_timestamp(tools.date_now_strymd())
# # dispoes_day = (PRIMERS_DAY*data) + now_date_day
# # print (tools.timestamp_to_str(dispoes_day))
# #print(seting.get_last(seting))
# print(setting_constr.timestamp(setting_constr))

# li=['afsafs','dsfasdfsdaf','adsfsadgerg','trh45b4b4g','g31vrvsdvge','g4brb3efr']
# for index in range(len(li)):
#     print(index+1,li[index])

# from Base.tools import tools
# print(tools.date_now_timestamp())

# from Text.TextDispose import log_dispose
#
# ls=log_dispose()
# print(ls.need_date(name_list=ls.get_filename_alllist()))
#
# import urllib,random
# import urllib.request
#
# def get(url,proxies):
#     random_proxy = random.choice(proxies)
#     proxy_support = urllib.request.ProxyHandler({"http": random_proxy})
#     opener = urllib.request.build_opener(proxy_support)
#     urllib.request.install_opener(opener)
#
#
#
# url = "http://club.autohome.com.cn/bbs/thread-c-3059-66611960-1.html"
# #添加代理列表，可以自行去百度获取
# proxies =["121.232.145.202:9000","59.34.131.103:8080","123.55.2.131:808","101.200.82.141:8888","58.59.172.177:9797","121.232.145.63:9000"]
# user_agent ="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.63 Safari/537.36"
# headers = {'User-Agent':user_agent}
# req = urllib.request.Request(url, headers=headers)
# i = 1
# while 1:
#     #添加参数
#     code = get(url,proxies)
#     print('第'+str(i)+'次代理访问:'+str(code))
#     i +=1

import urllib.request
import timeit
import threading
import time
import webbrowser,os
# i = 0
# mylock = threading._allocate_lock()
#
#
# def test():
#     global i
#     url = 'http://club.autohome.com.cn/bbs/thread-c-3059-66611960-1.html'
#     for j in range(1, 50):
#         req = urllib.request
#         #req.add_header("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)")
#         file = urllib.request.urlopen(req)
#         print(file.getcode())
#         mylock.acquire()
#         i += 1
#         mylock.release()
#         print(i)
#         threading.exit_thread()

# def shu():
#     while True:
#         #webbrowser.open('http://club.autohome.com.cn/bbs/thread-c-3059-66611960-1.html')
#         webbrowser.open('http://club.autohome.com.cn/bbs/thread-c-3059-66868219-1.html')
#         #webbrowser.open('http://club.autohome.com.cn/bbs/thread-c-3059-66346404-1.html')
#         #webbrowser.open('http://club.autohome.com.cn/bbs/thread-c-3059-65902310-1.html')
#         time.sleep(10)
#         os.system('taskkill /F /IM iexplore.exe')
#         os.system('taskkill /F /IM chrome.exe')
#         os.system('taskkill /F /IM opera.exe')
#         os.system('taskkill /F /IM SogouExplorer.exe')
#         time.sleep(5)
#
# t1=threading.Thread(target=shu)
# t2=threading.Thread(target=shu)
# t3=threading.Thread(target=shu)
# t4=threading.Thread(target=shu)
# t5=threading.Thread(target=shu)
# t6=threading.Thread(target=shu)
# t7=threading.Thread(target=shu)
# t8=threading.Thread(target=shu)
# t9=threading.Thread(target=shu)
# t10=threading.Thread(target=shu)
# # t11=threading.Thread(target=shu)
# # t12=threading.Thread(target=shu)
# # t13=threading.Thread(target=shu)
# # t14=threading.Thread(target=shu)
# # t15=threading.Thread(target=shu)
# # t16=threading.Thread(target=shu)
# # t17=threading.Thread(target=shu)
# # t18=threading.Thread(target=shu)
# # t19=threading.Thread(target=shu)
# # t20=threading.Thread(target=shu)
#
#
# threa=[t1,t2,t3,t4,t5]
# for t in threa:
#     t.setDaemon(True)
#     t.start()
# t.join()
# time.sleep(10)

# time.sleep(15)

# from Model.DBL import seting
#
# obj=seting(None,None,None)
# print(obj.getperform_nmber())

# from contrl.file_list_task import file_list
# file=file_list()
# print(file.file_list_dispose())

# import time
# from Base.tools import tools
# print(tools.str_to_timestamp(tools.date_now_strymd()))
# str='2017-09-19'
# print(time.mktime(time.strptime(str,'%Y-%m-%d')))
# date='20170518'
# import datetime,time
# str=time.strptime(date, '%Y%m%d')
# print(time.strftime('%Y-%m-%d', str))
# from contrl.logdispose_contrll import LogDisposeContrll
# ls=LogDisposeContrll()
# ls.DelayTime()
# from celery import Celery
# from celery.schedules import crontab
# from contrl.logdispose_contrll import LogDisposeContrll
# import time
# #app = Celery('test', broker='redis://localhost:6379//')
# app = Celery('test', broker='amqp://guest@localhost:5672//')
# @app.task
# def LogDispose():
#     # logdispose=LogDisposeContrll()
#     # logdispose.LogDisposeTask()
#     a='hhh'
#     d='ahc'
#     b=a+d
#     return b
#
# app.conf.beat_schedule = {
#     'add-every-monday-morning': {
#         'task': 'test.LogDispose',
#         'schedule':crontab(),
#     },
# }

# rel=(False, True, True, True, True, True, None)
# if type(rel) != tuple:
#     print('rel.type != tuple or !=list')
